Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct off-by-one problem in EKF IMU ringbuffer #26696

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

peterbarker
Copy link
Contributor

This is an alternate solution to a bug @luweiagi found in the EKF buffer code.

His PR is here: #25316

My formulation here switches the determination of whether the buffer has ever been full to looking for us wrapping the new offset, rather than looking at the old offset.

I think all of these approaches are bogus; if we advance the oldest pointer then we may never actually be "full". I think the current behaviour only works because the EKF doesn't consume until the buffers have been full at least once.

The supplied tests fail before this PR, pass after (the buffer says it is full on the third element, not the fourth, as @luweiagi pointed out in the issue).

Closes #25316

@peterbarker peterbarker changed the title Pr/rinbuffer tests Correct off-by-one problem in EKF IMU ringbuffer Apr 5, 2024
Copy link
Contributor

@rmackay9 rmackay9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after the two minor fixes

peterbarker and others added 3 commits April 9, 2024 15:38
this init() call can be called on an existing buffer, in which case we clear the object.

Presumably since we've just zeroed all the elements its safe to say that we should mark the object as having never-been-filled
@peterbarker peterbarker merged commit cd8f081 into ArduPilot:master Apr 10, 2024
91 checks passed
@peterbarker peterbarker deleted the pr/rinbuffer-tests branch April 10, 2024 12:19
@luweiagi
Copy link
Contributor

I think there is a more correct fix at:
#25316 (comment)

@rmackay9
Copy link
Contributor

@luweiagi,

Oh oh. I've added this back for discussion at next week's dev call so that it's not forgotten in case PeterB doesn't have time to look into it before then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EKF_Buffer: there is a bug in ekf_imu_buffer::push_youngest_element(const void *element)
4 participants